package com.dao.impl;

import com.dao.ClazzDao;
import com.entity.Clazz;
import com.mapper.ClazzMapper;
import com.page.PageInfo;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("clazzDao")
public class ClazzDaoImpl implements ClazzDao {
    @Resource
    public ClazzMapper clazzMapper;
    @Override
//    public List<Clazz> getClazzByPage(PageInfo pageInfo) {
//        ClazzExample clazzExample = new ClazzExample();
//        clazzExample.setOffset(pageInfo.getOffset());
//        clazzExample.setLimit(pageInfo.getPageSize());
//        return clazzMapper.selectByExample(clazzExample);
//    }

    public List<Clazz> getClazzByPage(PageInfo pageInfo)  throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("currPage",pageInfo.getCurrPage());
        map.put("pageSize",pageInfo.getPageSize());
        System.out.println("111");
        return clazzMapper.getClazzsByPage(map);
    }

    @Override
    public Clazz getClazzById(String cno) throws Exception {
        return clazzMapper.selectByPrimaryKey(cno);
    }
    @Override
    public  Clazz getClazzByIdWithStudents(String cno) throws Exception{
        return clazzMapper.getClazzByIdWithStudents(cno);
    }
}
